<?php

class UcPreviewListController extends Controller
{
	// Uncomment the following methods and override them if needed
	/*
	public function filters()
	{
		// return the filter configuration for this controller, e.g.:
		return array(
			'inlineFilterName',
			array(
				'class'=>'path.to.FilterClass',
				'propertyName'=>'propertyValue',
			),
		);
	}

	public function actions()
	{
		// return external action classes, e.g.:
		return array(
			'action1'=>'path.to.ActionClass',
			'action2'=>array(
				'class'=>'path.to.AnotherActionClass',
				'propertyName'=>'propertyValue',
			),
		);
	}
	*/


    /*
    * 获取列表
    *
    */
    public function actionGetList()
    {
        try {
            //参数验证

            //检测
            //$user_id = SessionService::getUserIDBySessionid();

            //参数列表
            $type_id = Util::getParamNotEmpty("type_id");


            //获取列表
            $searchsql = Util::initSearchSql();

            $searchsql = Util::getSerarchStr($searchsql, "type_id", "type_id");

            //排序
            $searchsql = $searchsql . " order by create_time  desc";
            //获取list
            $list = UcPreviewList::model()->findAll($searchsql);


            //插入worker信息
            foreach($list as $key => $value){
                $list[$key]->worker = WorkerService::formatWorker(Worker ::model()->findByPK($list[$key] -> worker_id));
            }
                //返回数据
                Util::responseList(count($list), $list);


            } catch (Exception $e) {
            Util::responseErrorMsg($e->getMessage());

        }
    }
}